package com.sk.bilibili.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * @author 邵康
 * @date 2021/11/23 9:55
 */
public class QueryWrapperUtils {

    /**
     * 参数必须成对  一个名字  一个  值
     */
    public static <T> QueryWrapper<T> eq(Object...param){
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        for (int i = 0; i < param.length; i+=2) {
            wrapper.eq((String) param[i],param[i+1]);
        }
        return wrapper;
    }

    public static <T> QueryWrapper<T> ne(Object...param){
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        for (int i = 0; i < param.length; i+=2) {
            wrapper.ne((String) param[i],param[i+1]);
        }
        return wrapper;
    }

    /**
     * 小于等于
     */
    public static <T> QueryWrapper<T> le(Object...param){
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        for (int i = 0; i < param.length; i+=2) {
            wrapper.le((String) param[i],param[i+1]);
        }
        return wrapper;
    }

    public static <T> QueryWrapper<T> ge(Object...param){
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        for (int i = 0; i < param.length; i+=2) {
            wrapper.ge((String) param[i],param[i+1]);
        }
        return wrapper;
    }

}
